//
//  Title_TF_TableViewCell.m
//  youxi
//
//  Created by SHkingwelan on 17/3/2.
//  Copyright © 2017年 yph. All rights reserved.
//

#import "Title_TF_TableViewCell.h"

@interface Title_TF_TableViewCell()<UITextFieldDelegate>

@end

@implementation Title_TF_TableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code

    self.textTf.delegate = self;
    
    self.maxStringNumber = 200;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initView];
    }
    return self;
}

- (void)initView {
    //标题
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textColor = Text_Color_333333;
    self.titleLabel.text = @"联系人：";
    self.titleLabel.font = BHFont_Size_15;
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.width.offset([BHSettingUtil widthForText:@"联系人电话：" fontSize:15]-10);
    }];
    
    //简介
    self.textTf = [[UITextField alloc]init];
//    self.textTf.textColor = Text_Color_686868;
//    self.textTf.text = @"简介：公司特与世纪联华超市股份有限公司汽车本着“客户至上，质量为本”的原";
    self.textTf.font = BHFont_Size_13;
    self.textTf.delegate = self;
    [self.contentView addSubview:self.textTf];
    [self.textTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.titleLabel.mas_right).offset(0);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.height.equalTo(self.contentView.mas_height).offset(-5);
    }];
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
    if (self.myBlock) {
//        if (textField.text.length > self.maxStringNumber) {
//            self.myBlock([NSString stringWithFormat:@"最多输入%ld个字数", self.maxStringNumber]);
//        } else {
            self.myBlock(textField.text);
//        }
    }
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
    return YES;
}

@end
